package com.example.searchservice.controller;

import com.example.searchservice.service.impl.HanLPServiceImpl;
import com.google.gson.Gson;
import com.hankcs.hanlp.seg.common.Term;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/hanlp")
public class HanLPController {
    @Autowired
    private HanLPServiceImpl hanLPService;

    @Autowired
    private Gson gson;

    @PostMapping("/segment")
    public List<Term> segmentText(@RequestParam String text) {
        List<Term> list = hanLPService.segment(text);
        return list;
    }

    @PostMapping("/keywords")
    public List<String> extractKeywords(@RequestParam String content, @RequestParam(defaultValue = "5") int amount) {
        return hanLPService.extractKeyword(content, amount);
    }
}